package com.qf.erpb.sale.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.erpb.core.vo.PageVO;
import com.qf.erpb.sale.dao.SaleOrderDao;
import com.qf.erpb.sale.entity.SaleOrder;
import com.qf.erpb.sale.param.SaleOrderParam;
import com.qf.erpb.sale.service.SaleOrderService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 销售订单表(SaleOrder)表服务实现类
 *
 * @author makejava
 * @since 2023-12-18 17:08:10
 */
@Service("saleOrderService")

public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderDao, SaleOrder> implements SaleOrderService {
    @Resource
    private SaleOrderDao saleOrderDao;

    @Override
    public PageVO<SaleOrder> pageSaleOrder(SaleOrderParam saleOrderParam) {
        Page<SaleOrder> page = new Page<>(saleOrderParam.getPageNum(), saleOrderParam.getPageSize());
        QueryWrapper<SaleOrder> wrapper = new QueryWrapper<SaleOrder>();
//      if 判断 模糊查询的
        if (StringUtils.hasLength(saleOrderParam.getCustomName())){
            wrapper.like("custom_name",saleOrderParam.getCustomName());
        }
//        模糊查询条件地址
        if (StringUtils.hasLength(saleOrderParam.getAdress())){
            wrapper.like("adress",saleOrderParam.getAdress());
        }
//
        page = saleOrderDao.selectPage(page,wrapper);
        PageVO<SaleOrder> pageVO = new PageVO<>();
        pageVO.setTotal(page.getTotal());
        pageVO.setDataList(page.getRecords());
        return pageVO;
    }

//    批量插入
    @Override
    public int saveBatch(ArrayList<SaleOrder> list) {
        return saleOrderDao.saveBatch(list);
    }

    @Override
    public Map<String, Object> selectOne(Long id) {
        return saleOrderDao.selectOne(id);
    }

    @Override
    public List<Map<String, Object>> selectAll() {
        return saleOrderDao.selectAll();
    }

    @Override
    public List<Map<String, Object>> findmoneypeople() {
         return saleOrderDao.findmoneypeople();
    }

    @Override
    public List<Map<String, Object>> findmoneypeople1() {
        return saleOrderDao.findmoneypeople1();
    }

    @Override
    public List<Map<String, Object>> findmoneypeople3() {
        return saleOrderDao.findmoneypeople3();
    }


}
